package com.blrs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.enums.BusinessType;
import com.blrs.domain.FileChangeRecord;
import com.blrs.service.file.IFileChangeRecordService;
import com.blrs.common.utils.poi.ExcelUtil;
import com.blrs.common.core.page.TableDataInfo;

/**
 * 文件变更记录Controller
 * 
 * @author ruoyi
 * @date 2023-11-06
 */
@RestController
@RequestMapping("/file/change")
public class FileChangeRecordController extends BaseController
{
    @Autowired
    private IFileChangeRecordService fileChangeRecordService;

    /**
     * 查询文件变更记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(FileChangeRecord fileChangeRecord)
    {
        startPage();
        List<FileChangeRecord> list = fileChangeRecordService.selectFileChangeRecordList(fileChangeRecord);
        return getDataTable(list);
    }

    /**
     * 导出文件变更记录列表
     */
    @Log(title = "文件变更记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FileChangeRecord fileChangeRecord)
    {
        List<FileChangeRecord> list = fileChangeRecordService.selectFileChangeRecordList(fileChangeRecord);
        ExcelUtil<FileChangeRecord> util = new ExcelUtil<FileChangeRecord>(FileChangeRecord.class);
        util.exportExcel(response, list, "文件变更记录数据");
    }

    /**
     * 获取文件变更记录详细信息
     */
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") String recordId)
    {
        return success(fileChangeRecordService.selectFileChangeRecordByRecordId(recordId));
    }

    /**
     * 新增文件变更记录
     */
    @Log(title = "文件变更记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FileChangeRecord fileChangeRecord)
    {
        return toAjax(fileChangeRecordService.insertFileChangeRecord(fileChangeRecord));
    }

    /**
     * 修改文件变更记录
     */
    @Log(title = "文件变更记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FileChangeRecord fileChangeRecord)
    {
        return toAjax(fileChangeRecordService.updateFileChangeRecord(fileChangeRecord));
    }

    /**
     * 删除文件变更记录
     */
    @Log(title = "文件变更记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable String[] recordIds)
    {
        return toAjax(fileChangeRecordService.deleteFileChangeRecordByRecordIds(recordIds));
    }
}
